package com.itheima.demo;

// lombok技术可以实现为类自动添加getter setter方法 无参数构造器，toString方法等。
public class Card {
    private String carId; // 车牌号码
    private String name;
    private String phone;
    private double money; // 余额

    // Default constructor
    public Card() {
    }

    // All args constructor
    public Card(String carId, String name, String phone, double money) {
        this.carId = carId;
        this.name = name;
        this.phone = phone;
        this.money = money;
    }

    // Getters and Setters
    public String getCarId() {
        return carId;
    }

    public void setCarId(String carId) {
        this.carId = carId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    // 预存金额。
    public void deposit(double money) {
        this.money += money;
    }

    // 消费金额。
    public void consume(double money) {
        this.money -= money;
    }

    @Override
    public String toString() {
        return "Card{" +
                "carId='" + carId + '\'' +
                ", name='" + name + '\'' +
                ", phone='" + phone + '\'' +
                ", money=" + money +
                '}';
    }
}
